<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['base_path']?>public/css/style.css" media="screen" />
        <link rel="shortcut_icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.ico" />
		<link rel="icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.png" />
		<title>Foto</title>
        <script type="text/javascript" src="<?php echo $GLOBALS['base_path']?>public/js/fquery.js"></script>
        <script type="text/javascript">
            function reload() {
                var page = document.getElementById("more").getAttribute("class");
                var href = document.getElementById("more").getAttribute("href");
                document.getElementById("more").setAttribute("class", parseInt(page) + 1);
                ajaxGet(href + "?page=" + page , function(result) {
                    document.getElementById("wallList").innerHTML = "";
                    document.getElementById("wallList").innerHTML = result;
                });
                return false;
            }

            function init() {
                var elements = getElementsByClassName("pagination", null , null);
                for (var i in elements) {
                    elements[i].onclick = function() {
                        ajaxGet(this.getAttribute('href') , function(result) {
                            document.getElementById('photosContainer').innerHTML = result;
                        });
                        return false;
                    }
                }
            }
        </script>
    </head>
    <body onload="init();">
        <div id="bodyWrapper">
            <?php $this->render('accountbar');?>
            <div class="dummy"></div>
            <?php $this->render('menubar');?>

            <div id="content">
                <div id="profileLeft">
                    <h2><?php echo $user->fullname;?></h2>
                    <img class="profilePictureThumb" src="<?php if($user->getProfilePicture() != NULL) echo $user->getProfilePicture()->getUrl();?>" alt="" />
                    <br />
                    <?php if ($this->auth != null) : ?>
                        <?php if ($this->auth->id != $user->id) : ?>
                            <?php if (!$this->auth->isFollowing($user)) :?>
                                <a href="<?php echo $this->createUrl('profile/follow/' . $user->id);?>">Ikuti</a>
                            <?php else:?>
                                <a href="<?php echo $this->createUrl('profile/unfollow/' . $user->id);?>">Jangan ikuti</a>
                            <?php endif;?>
                            <a href="<?php echo $this->createUrl('profile/message/' . $user->id);?>">Kirim pesan</a>
                        <?php else :?>
                            <a href="<?php echo $this->createUrl('profile/edit');?>">Ubah Profil</a>
                        <?php endif;?>
                        <?php if ($user->isWallAllowed($this->auth) || $user == $this->auth) : ?>
                            <form id="wallForm" method="POST" action="<?php echo $this->createUrl('profile/postwall/' . $user->id)?>">
                                <textarea name="wall" cols="30" rows="5"></textarea><br />
                                <input type="submit" value="POST!" />
                            </form>
                        <?php endif;?>
                    <?php endif;?>
                    <div id="wallList">
                    <?php foreach($walls as $wall) :?>
                        <div class="myWall">
                            <div class="myWallCommentPhoto"><img src="<?php if($wall->getPoster()->getProfilePicture() != NULL) echo $wall->getPoster()->getProfilePicture()->getUrl();?>" alt="" /></div>
                            <div class="myWallCommentPoster"><a href="<?php echo $this->createUrl('profile/view/' . $wall->getPoster()->id);?>"> <?php echo $wall->getPoster()->fullname;?></a></div>
                            <div class="myWallCommentContent"><?php echo $wall->content?></div>
                                <?php foreach($wall->getChildWalls() as $w) : ?>
                                <div class="myWallComment">
                                    <div class="myWallCommentPhoto"><img src="<?php if($w->getPoster()->getProfilePicture() != NULL) echo $w->getPoster()->getProfilePicture()->getUrl();?>" alt="" /></div>
                                    <div class="myWallCommentPoster"><a href="<?php echo $this->createUrl('profile/view/' . $user->id);?>"> <?php echo $w->getPoster()->fullname;?></a></div>
                                    <div class="myWallCommentContent"><?php echo $w->content?></div>
                                </div>
                                <?php endforeach;?>
                            <div class="myWallComment">
                                <form action="<?php echo $this->createUrl('profile/commentwall/' . $wall->id);?>" method="post">
                                    <input class="commentWallText" type="text" name="commentwall" value="Write your comment..." onfocus="this.value=''" onblur="this.value='Write your comment...'" />
                                </form>
                            </div>
                        </div>
                    <?php endforeach;?>
                    </div>
                    <a onclick="return reload();" id="more" class="2" href="<?php echo $this->createUrl('profile/getAllWall/' . $user->id);?>">More</a>
                    <br /><br /><br />
                </div><!-- div id="profileLeft" -->
                <div id="profileRight">
                    <div id="followerList">
                        <h2>Pengikut</h2>
                        <?php foreach($user->getFollowers() as $follower) : ?>
                            <div class="profileWrapper">
                                <div class="profile">
                                    <a href="<?php echo $this->createUrl('profile/view/'.$follower->id);?>"><img src="<?php if($follower->getProfilePicture() != NULL) echo $follower->getProfilePicture()->getUrl();?>" alt="" title="<?php echo $follower->fullname ?>"/></a>
                                    <!--<br />-->
                                    <?php //echo $follower->getProfileLink();?>
                                </div>
                                <div class="profileInviteChat">
                                    <a href="<?php echo $this->createUrl('chat/room/'.$follower->id); ?>"><img src="<?php echo $GLOBALS['base_path']?>public/img/chat2.png" height="20" width="20" title="Chat with <?php echo $follower->fullname ?>"></img></a>
                                </div>
                            </div>
                        <?php endforeach;?>
                    </div>
                    <br/>
                    <div id="followedList">
                        <h2>Mengikuti</h2>
                        <?php foreach($user->getFollowed() as $follower) : ?>
                            <div class="profileWrapper">
                                <div class="profile">
                                    <a href="<?php echo $this->createUrl('profile/view/' . $follower->id)?>"><img src="<?php if($follower->getProfilePicture() != NULL) echo $follower->getProfilePicture()->getUrl();?>" alt="" title="<?php echo $follower->fullname ?>"/></a>
                                    <!--<br />-->
                                    <?php //echo $follower->getProfileLink();?>
                                </div>
                                <div class="profileInviteChat">
                                    <a href="<?php echo $this->createUrl('chat/room/'.$follower->id); ?>"><img src="<?php echo $GLOBALS['base_path']?>public/img/chat2.png" height="20" width="20" title="Chat with <?php echo $follower->fullname ?>"></img></a>
                                </div>
                            </div>
                        <?php endforeach;?>
                    </div>
                    <br/>
                    <div id="photoList">
                        <h2>Foto - foto</h2>
                        <div id="photosContainer">
                            <?php foreach($photos as $photo) : ?>
                            <div class="photoThumb">
                                <a href="<?php echo $this->createUrl('photo/detail/'. $photo->id);?>">
                                    <img src="<?php echo $photo->getUrl();?>" alt="" />
                                </a>
                            </div>
                            <?php endforeach;?>
                        </div>
                        <div class="dummy"></div>
                        <?php $pagin->render();?>
                    </div>
                </div><!-- div id="profileRight" -->
                <div class="dummy">
                    
                </div>
            </div>
        </div>
    </body>

</html>